package JAVA300.第十一章多线程;

/**
 * 学习可重入锁，锁可以套娃使用
 */
public class thread_19_others_7reEntryLock {

    public void test(){
        //第一次获锁
        synchronized (this){
            while (true){
                synchronized (this){
                    System.out.println("ReEntryLock");
                }

                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }


            }
        }
    }

    public static void main(String[] args) {
        new thread_19_others_7reEntryLock().test();//循环输出ReEntryLock
    }

}
